package com.xhsd.zlong.generatecode.model.impl.mysql;

import java.sql.Date;

/**
 * mysql 数据类型简单转换,有待完善
 * @author zlong
 *
 */
public class MysqlTypes {
	private static final String LONG = "LONG";
	private static final String INT="INT";
	private static final String CHAR="CHAR";
	private static final String FLOAT="FLOAT";
	private static final String DOUBLE="DOUBLE";
	private static final String DATE="DATE";

	public static Class<?> getJavaTypeFromMysqlType(String type){
		if(type.contains(MysqlTypes.CHAR)||type.contains((MysqlTypes.CHAR.toLowerCase()))){
			return String.class;
		}else if(type.contains(MysqlTypes.INT)||type.contains((MysqlTypes.INT.toLowerCase()))){
			return Integer.class;
		}else if(type.contains(MysqlTypes.LONG)||type.contains((MysqlTypes.LONG.toLowerCase()))){
			return Long.class;
		}else if(type.contains(MysqlTypes.FLOAT)||type.contains((MysqlTypes.FLOAT.toLowerCase()))) {
			return Float.class;
		}else if(type.contains(MysqlTypes.DOUBLE)||type.contains((MysqlTypes.DOUBLE.toLowerCase()))){
			return Double.class;
		}else if(type.contains(MysqlTypes.DATE)||type.contains((MysqlTypes.DATE.toLowerCase()))){
			return Date.class;
		}else{
			return String.class;
		}
	}
}
